﻿@using RiderShop.Mobile.Common.Component

@{
    ViewBag.Title = "商品列表";
}
@{ Html.RenderAction("SearchPartial", "Home"); }   
<!-- InstanceBeginEditable name="Body" -->

@if (Model.Result.Data.Count == 0)
{
  <div class="noresult">
    <h1>十分抱歉，我们没有找到与 <strong class="red">"@Model.Keyword"</strong>的相关的商品</h1>
    <p>1、看看输入的文字是否有误</p>
    <p>2、可尝试对搜索关键词根据其词义来进行拆分，输入多个词语搜索，可以获得更精确的搜索结果。<br>
      <span class="blue">例如：搜索“福临门响水米”，可以改为搜索“福临门 响水米”</span>
    </p>
</div>
}
else
{
  <form action="~/Product/ProductList" id="productList">
    <select name="SortField" id="SortField" category="@Model.SubcategoryCode">
        @foreach (var item in Model.SearchCondition)
        {
            if (Model.FiterIndex == item.Value)
            {
                <option value="@item.Value" selected="selected">@item.Key</option>
            }
            else
            {
                <option value="@item.Value">@item.Key</option>
            }
        }
    </select>
</form>
}
@foreach (var item in Model.Result.Data)
{
    <ul data-role="listview" data-inset="flase">
        <li data-theme="none" data-icon="false">
            <a href="~/Product/ProductDetail?prd=@item.ProductId" class="product-listlink">
                <div class="pListContainer mb5">
                    <ul class="plistul">
                        <li class="pList-item">
                            <div class="num_warp_list_top_white">
                                <div class="prdListItemImage fl">
                                    <div class="iconPromB" >
                                        @if (!string.IsNullOrEmpty(@item.PromotionTypeStr))
                                        {
                                            <img class="png"  src="@item.PromotionTypeIcon" alt="" />
                                        }    
                                    </div>
                                    <img id="prdListImage"  
                                        src="@item.ActualImageUrl" alt="@item.Title"/>   
                                </div>
                                <div class="prdListItemTitle fl">
                                    <h3 class="f14 normalwrap">@item.Title</h3>
                                    <div class="viewdesc ml10 mb5 normalwrap">
                                        <div>
                                            @Html.Raw(@item.ViewDescription)
                                        </div>
                                    </div>
                                    <div class="price">￥@item.UnitPrice</div>
                                    <div class="koubei ml5">
                                        <span class="fl">已有(@item.ReviewCount)人评价</span>
                                        <span class="rating fl"><span style="width:@item.ReviewCount%" class="value"></span></span>
                                    </div>
                                </div>
                                     
                            </div>
                        </li>
                    </ul>
                </div>
            </a>
        </li>
    </ul>
}
<div>@Html.Pagination((int)ViewBag.PageSize, (int)ViewBag.Index, (int)ViewBag.RecordCount, null)</div>

<script language="javascript" type="text/javascript">
        $(document).ready(function() {
            $("#SortField").change(function () {
                var seelctIndex = $(this).children('option:selected').val();
                var category = $("#SortField").attr("category");
                var par = "";
                switch (seelctIndex) {
                    case "1"://lower unit price
                        par = "&sort=1&order=7";
                        break;
                    case "2"://most review
                        par = "&sort=0&order=2";
                        break;
                    case "3"://up unit price
                        par = "&sort=1&order=0";
                        break;
                    case "4"://up unit price
                        par = "&sort=0&order=0";
                        break;
                    case "5"://active date
                        par = "&sort=0&order=1";
                        break;
                default:
                }
                var url = document.forms["productList"].action;
                window.location = url + "?findex=" + seelctIndex + "&sid=" + category + par;
            });
        });
</script>